package com.youkeyi.ddy.cloud.common.api.application.system.login;

import com.youkeyi.ddy.cloud.common.api.application.system.login.param.LoginAuthCloudParam;
import com.youkeyi.ddy.cloud.common.response.ResponseContent;
import com.youkeyi.ddy.cloud.common.response.ResponseObjectContent;
import io.swagger.annotations.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录授权相关接口
 *
 * @Author liuxiawang
 * @Date 2021-04-08 17:37
 * @Location shenzhen.china
 */
@Api(tags = {"【SYSTEM】Login"})
@RestController
@RequestMapping("/system/login")
@FeignClient(value = "YOUKEYI-DDY-CLOUD-APPLICATION-SYSTEM", fallback = SystemLoginFeignServiceFallback.class)
public interface SystemLoginFeignService {

    /**
     * 获取登录需要用的安全码数据.
     *
     * @return the auth code
     */
    @GetMapping("/code")
    @ApiOperation(value = "登录需要用的安全码数据", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.getAuthCode")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query"),
    })
    public abstract ResponseContent getAuthCode(HttpServletRequest request, HttpServletResponse response);

    /**
     * 登录.
     *
     * @param param the param
     * @return the response content
     */
    @PostMapping(value = "/login")
    @ApiOperation(value = "登录", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.login")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseObjectContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body"),
    })
    public abstract ResponseObjectContent login(HttpServletRequest request, HttpServletResponse response, @RequestBody LoginAuthCloudParam param);

    /**
     * 登出.
     *
     * @return the response content
     */
    @GetMapping("/logout")
    @ApiOperation(value = "登出", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.logout")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query"),
    })
    public abstract ResponseContent logout(HttpServletRequest request, HttpServletResponse response);




    /**
     * web端小程序授权登陆：获取授权链接
     *
     * @return the auth code
     */
    @GetMapping("/authorization/link")
    @ApiOperation(value = "获取授权链接", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.getAuthorizationLink")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query"),
    })
    public abstract ResponseContent getAuthorizationLink(HttpServletRequest request, HttpServletResponse response);

    /**
     * web端小程序授权登陆：查询授权状态，完成授权之后直接登陆返回token等
     *
     * @return the auth code
     */
    @PostMapping("/authorization/{gid}")
    @ApiOperation(value = "查询授权状态，完成授权之后直接登陆完成", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.authorizationLogin")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseObjectContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body"),
    })
    public abstract ResponseObjectContent authorizationLogin(HttpServletRequest request, HttpServletResponse response, @PathVariable("gid") String gid);

    /**
     * web端小程序授权登陆：小程序上操作"授权登陆"
     *
     * @return the auth code
     */
    @PostMapping("/applet/authorization")
    @ApiOperation(value = "小程序上操作<授权登陆>", authorizations = {@Authorization("com.youkeyi.ddy.cloud.common.api.application.system.login.SystemLoginFeignService.authorization")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body", value = "Param of Upload File", dataType = "LoginAuthCloudParam", dataTypeClass = LoginAuthCloudParam.class),
    })
    public abstract ResponseContent authorization(@RequestBody LoginAuthCloudParam param);
}
